package com.sun.spring5.annotations;

import org.springframework.core.io.Resource;
import org.springframework.core.type.AnnotationMetadata;
import org.springframework.core.type.ClassMetadata;
import org.springframework.core.type.classreading.MetadataReader;
import org.springframework.core.type.classreading.MetadataReaderFactory;
import org.springframework.core.type.filter.TypeFilter;

import java.io.IOException;


public class MyTypeFilter implements TypeFilter {
    @Override
    public boolean match(MetadataReader metadataReader, MetadataReaderFactory metadataReaderFactory) throws IOException {
        //当前类注解得信息
        AnnotationMetadata annotationMetadata = metadataReader.getAnnotationMetadata();
        //当前类注解得类信息
        ClassMetadata classMetadata = metadataReader.getClassMetadata();
        String className = classMetadata.getClassName();
        if (className.equals("person")){
            System.out.println("==============>"+className);
            return true;
        }
        //获取当前类得资源信息(类路径)
        Resource resource = metadataReader.getResource();

        return false;
    }
}
